<?php

namespace App\Repositories\Config;


use App\Models\GameTool\GameItem;

class GameItemRepository
{

    public function getByCondition($condition)
    {
        //$query = GameItem::query();
        $where = '';
        if (isset($condition['game_id'])) {
            $where = " WHERE game_id='{$condition['game_id']}' ";
        }

        $sql = "SELECT
                    CONCAT(item_type,'-',item_id) AS item_key,
                    item_name 
                FROM
                    mc_game_items
                {$where}
                ORDER BY updated_at DESC";

        //return $query->orderBy('updated_at', 'DESC')->pluck('item_name', 'item_id')->toArray();
        //return GameItem::query()->raw($sql)->pluck('item_name', 'item_key')->toArray();

        $items = \DB::select($sql);
        return $items;
    }
}